package com.shuting.Analysis_PersonClassifyPaper;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

//用静态常量的形式存储配置文件的信息
public class ConfigInf implements Serializable {
   
	static ArrayList<String> placeSet=null;
	static Map<String,Double> journalSet=null;
   
	public static void initPlaceSet(String placePath) {
	  
		placeSet=new ArrayList<String>();
		  
		Configuration conf = new Configuration();
		try	{			
			FileSystem fs = FileSystem.get(URI.create(placePath),conf);
			FSDataInputStream fsr = fs.open(new Path(placePath));
			BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fsr));	
			String lineStr="";			
			while((lineStr=bufferedReader.readLine())!=null){
				placeSet.add(lineStr);
			}			
			bufferedReader.close();		
		}catch (Exception e){			
			e.printStackTrace();
		}		
	}
	
	public static void initJournalMap(String journalPath) {
		
		journalSet=new HashMap<String,Double>();
		  
		Configuration conf = new Configuration();
		try	{			
			FileSystem fs = FileSystem.get(URI.create(journalPath),conf);
			FSDataInputStream fsr = fs.open(new Path(journalPath));
			BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fsr));	
			String lineStr="";			
			while((lineStr=bufferedReader.readLine())!=null){
				
				String journal=lineStr.split("->")[0];
				Double weight=Double.valueOf(lineStr.split("->")[1]);				
				journalSet.put(journal, weight);
			}			
			bufferedReader.close();		
		}catch (Exception e){			
			e.printStackTrace();
		}		
	}	
	
}